<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta name="description" content="">
  <meta name="author" content="Dashboard">
  <meta name="keyword" content="Dashboard, Bootstrap, Admin, Template, Theme, Responsive, Fluid, Retina">
  <title>奥利奥酒店客房管理系统</title>

  <!-- Favicons -->
<!--  <link href="../img/favicon.png" rel="icon">-->
<!--  <link href="../img/apple-touch-icon.png" rel="apple-touch-icon">-->

  <!-- Bootstrap core CSS -->
  <link href="/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet">
  <!--external css-->
  <link href="../lib/font-awesome/css/font-awesome.css" rel="stylesheet" />
  <!-- Custom styles for this template -->
  <link href="../css/style.css" rel="stylesheet">
  <link href="../css/style-responsive.css" rel="stylesheet">

  <style>

    body{
      background-image: url("/img/light1.jpg");
      background-size: cover;
    }
  </style>
</head>

<body>
  <!-- **********************************************************************************************************************************************************
      MAIN CONTENT
      *********************************************************************************************************************************************************** -->
  <div id="login-page">
    <div class="container">
      <form class="form-login" >
        <h2 class="form-login-heading">sign in now</h2>
        <div class="login-wrap">
          <input type="text" class="form-control" id="user_name" placeholder="请输入用户名" autofocus>
          <br>
          <input type="password" class="form-control"  id="user_pwd" placeholder="请输入用户密码">
          <br>
          <button class="btn btn-theme btn-block" type="button" onclick="check()"><i class="fa fa-lock"></i> 登录</button>
<!--          <hr>-->

        </div>
      </form>
    </div>
  </div>

  <!-- js placed at the end of the document so the pages load faster -->
  <script src="/jquery/jquery-3.4.1.js"></script>
  <script src="/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
  <!--BACKSTRETCH-->
  <!-- You can use an image of whatever size. This script will stretch to fit in any screen size.-->
  <script type="text/javascript" src="/jquery/jquery.backstretch.min.js"></script>
<!--  <script>-->
<!--    $.backstretch("img/back1.jpg", {-->
<!--      speed: 500-->
<!--    });-->

<!--  </script>-->

  <script type="text/javascript">
    //登录时检验账户密码是否正确

      function check() {
        var t=0;
        var userName = jQuery("#user_name").val();
        var password = jQuery("#user_pwd").val();
        jQuery.ajax({type:"POST",async:false,url:"/emp_all",dataType:"json", success: function (rst) {
          for (var i = 0; i < rst.length; i++) {
            var json = rst[i];
            if (userName == json.emp_name) {
              t++;
              if (password == json.emp_pin) {
                alert("登录成功！");
                window.location.href = "首页.html";
              }
              else {
                alert("用户密码错误！请重新输入");
                location.reload();
              }
            }
          }
          if(t< 1) {
            alert("该用户名不存在，请核对后重新输入");
            location.reload();
          }
        }});

        var name=jQuery("#user_name").val();
        var time=new Date();
        var exe_time = time.toLocaleString('chinese', { hour12: false })
        jQuery.post("/saveLog",{"time":exe_time,"person":name},function (rst){
          alert(rst);
          if(rst!="创建日志记录失败")
          {
            location.reload();
          }
        })
      }

  </script>

</body>


</html>
